import React from "react";
import { Table } from 'antd';
export default function NewsPublish (props) {
    const columns = [
        {
            title: '新闻标题',
            align: 'center',
            dataIndex: 'title',
            render: (title, item) => {
                return <a href={`#/news-manage/preview/${item.id}`}>{item.title}</a>
            }
        },
        {
            title: '作者',
            align: 'center',
            dataIndex: 'author'
        },
        {
            title: '新闻分类',
            align: 'center',
            dataIndex: 'category',
            render: (category) => {
                return <div>{category.title}</div>
            }
        },
         {
             title: '操作',
             align: 'center',
             render: (item) => {
                 return <div>
                     {props.button(item.id)}
                 </div>
             }
         }
    ]

    return(
        <div>
            <Table  dataSource={props.dataSource}
                    columns={columns}
                    rowKey= {item => item.id}
                    bordered>
            </Table>
        </div>
    )
}